package com.ayu.scalalearn.chapter08

/**
  * @Author 徐林玉
  * @Description Test01PatternMatch
  * @Date 2022/8/16 14:47
  * @Version 1.0
  */
object Test01PatternMatch {

  def main(args: Array[String]): Unit = {

    val x = 5

    val y = x match {

      case 1 => "ONE"
      case 2 => "TWO"
      case 3 => "THREE"
      case _ => "OTHER"
    }

    println(y)

    val a = 10

    val b = 11

    def matchDualOp(op: Char): Int = op match {

      case '+' => a + b
      case '-' => a - b
      case '*' => a * b
      case '/' => a / b
      case _ => -1
    }

    println(matchDualOp('/'))
    println(matchDualOp('*'))


  }


}
